import React, { Suspense } from 'react'
import { Router, Route, Redirect, Switch } from 'react-router-dom'
import AuthRoute from './components/AuthRoute'
import history from './utils/history'
const Login = React.lazy(() => import('@/pages/Login'))
const Layout = React.lazy(() => import('@/pages/Layout'))
const Edit = React.lazy(() => import('@/pages/Profile/Edit'))
const Chat = React.lazy(() => import('@/pages/Profile/Chat'))
const Feedback = React.lazy(() => import('@/pages/Profile/Feedback'))
const NotFound = React.lazy(() => import('@/pages/NotFound'))
function App() {
  return (
    <Router history={history}>
      <Suspense fallback={<div>loading...</div>}>
        <Switch>
          <Redirect exact from="/" to="/home"></Redirect>
          <Route path="/home" component={Layout}></Route>
          <Route path="/login" component={Login}></Route>
          <AuthRoute path="/profile/edit" component={Edit}></AuthRoute>
          <AuthRoute path="/profile/chat" component={Chat}></AuthRoute>
          <AuthRoute path="/profile/feedback" component={Feedback}></AuthRoute>
          <Route component={NotFound}></Route>
        </Switch>
      </Suspense>
    </Router>
  )
}

export default App
